package gui.fenetrage;

import gui.panels.Planche;

import java.awt.BorderLayout;

import javax.swing.JFrame;
import javax.swing.JPanel;
import javax.swing.WindowConstants;

public class GUIFenetrePrincipale extends JFrame {


	private static final long serialVersionUID = 1L;

	private JPanel				conteneurPlanche;

	public GUIFenetrePrincipale()
	{
		construire();
	}

	private void construire()
	{
		setDefaultCloseOperation(WindowConstants.EXIT_ON_CLOSE);
		setLayout(new BorderLayout());
		conteneurPlanche = new JPanel();

		setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE);

		conteneurPlanche.setLayout(new BorderLayout());

		conteneurPlanche.setRequestFocusEnabled(false);

		add(conteneurPlanche);


		pack();

	}

	public JPanel getConteneurPlanche() {
		return conteneurPlanche;
	}

	public void setPlanche(Planche p)
	{
		System.out.println("setPlanche");
		if (p != null)
		{
			System.out.println(p);
			conteneurPlanche.removeAll();
			conteneurPlanche.add(p, BorderLayout.CENTER);
			conteneurPlanche.updateUI();
			setTitle("Mme l'Ambassadrice 2007 - "+p.getNom());
			p.actionOuverture();
		}
	}

	private static boolean				hasInstance	= false;
	private static GUIFenetrePrincipale	instance;

	public static boolean hasInstance()
	{
		return hasInstance;
	}

	public static GUIFenetrePrincipale getInstance()
	{
		if (hasInstance())
		{
			return instance;
		} else
		{
			instance = new GUIFenetrePrincipale();
			hasInstance = true;
			return instance;
		}
	}

}
